package br.inf.solutions.apresentacoes.ssp.control.validator;

import java.util.Map;

import br.com.vexillum.util.Return;
import br.com.vexillum.util.SpringFactory;
import br.inf.solutions.apresentacoes.ssp.control.bulletin.BulletinAwaitItensController;

public class BulletinValidator extends BaseValidator {

	public BulletinValidator(Map<String, Object> mapData) {
		super(mapData);
	}

	public Return validateSetPersonForBulletin() {
		return validateAttribute("person");
	}
	
	public Return validateGenerateBulletinNumber() {
		Return ret = new Return(true);
		if(ret.isValid()){
			BulletinAwaitItensController awaitController = SpringFactory.getController("bulletinAwaitItensController", BulletinAwaitItensController.class, null);
			if(awaitController.getAllAwaitingItens().getList().isEmpty()){
				ret.concat(creatReturn(null, getValidationMessage(null, "noitenstopublicate", true)));
			}
		}
		return ret;
	}
	
}
